/*
 * Copyright  2011 Nokia Corporation.
 *
 * GE::GA Qt Audio out
 * tuomo.hirvonen@digia.com
 *
 */

#ifndef __GE_QTAUDIOOUT__
#define __GE_QTAUDIOOUT__

#include <QtCore/qobject.h>
#include <QtCore/qfile.h>
#include <QtMultimedia/qaudio.h>
#include <QtMultimedia/qaudiodeviceinfo.h>
#include <QtCore/qtimer.h>
#include <QtCore/qstring.h>
#include <QThread>

#include "GEInterfaces.h"


class QAudioOutput;

namespace GE {

class AudioOut : public QThread {
    Q_OBJECT

public:
    AudioOut(QObject *parent, GE::IAudioSource *source);
    virtual ~AudioOut();

    /*
     * call this manually only if you are not using thread(with Symbian)
     * Note, when using GE, windowwg owning the audioout will handle of
     * calling this.
     */
    void tick();
    bool usingThead() { return m_usingThread; }

private slots:
    // For internal notify "solution"
    void audioNotify();

protected:
    // This is for the threaded mode only
    virtual void run();

    bool m_usingThread;
    qint64 m_samplesMixed;

    QAudioOutput *m_audioOutput;
    QIODevice *m_outTarget;
    GE::IAudioSource *m_source;
    int m_runstate;
    AUDIO_SAMPLE_TYPE *m_sendBuffer;
    int m_sendBufferSize;
};
}

#endif
